
export default {
    state: {
        //当前的状态
        status:"matching",//matching表示匹配界面,playing表示对战界面,决定显示哪个组件
        //存前后端建立的链接是什么
        socket:null,
        //对手
        opponent_username:"",
        opponent_photo:"",
        gamemap: null,
        a_id: 0,
        a_sx: 0,
        a_sy: 0,
        b_id: 0,
        b_sx: 0,
        b_sy: 0,
        gameObject:null,
        loser:"none",//all（全输了）,A,B,none(没人输)
    },
    getters: {
    },
    mutations: {
        updateSocket(state,socket){//成功创建连接时需要把信息记入全局变量
            state.socket=socket;
        },
        updateOpponent(state,opponent){
            state.opponent_username=opponent.username;
            state.opponent_photo = opponent.photo;
        },
        updateStatus(state, status) {
            state.status = status;
        },
        //辅助函数更新地图
        updateGame(state, game) {
            //传进来地图和ab的id，ad的坐标
            state.gamemap = game.map;
            state.a_id = game.a_id;
            state.a_sx = game.a_sx;
            state.a_sy = game.a_sy;
            state.b_id = game.b_id;
            state.b_sx = game.b_sx;
            state.b_sy = game.b_sy;
        },
        updateGameObject(state,gameObject){
            state.gameObject=gameObject;
        },
        updateLoser(state, loser) {
            state.loser = loser;
        }
    },
    actions: {
    },
    modules: {
    }
}
